package com.eian.boot.module.system.permission.model.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

@Data
@Schema(name = "创建权限请求参数")
public class CreatePermissionRequest {
    @Schema(description = "父菜单ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "父菜单ID不能为空")
    @Min(value = 0, message = "父菜单ID不能小于0")
    private Long parentId;

    @Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "菜单名称不能为空")
    @Size(min = 2, max = 50, message = "菜单名称长度必须在2-50个字符之间")
    private String title;

    @Schema(description = "权限编码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "权限编码不能为空")
    @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "菜单编码必须以小写字母开头，只能包含小写字母、数字和下划线")
    private String code;

    @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "权限类型不能为空")
    @Range(min = 1, max = 3, message = "权限类型只能是1-目录，2-菜单，3-按钮")
    private Integer type;

    @Schema(description = "菜单URL路径")
    private String url;

    @Schema(description = "菜单图标")
    private String icon;

    @Schema(description = "前端组件路径")
    private String component;

    @Schema(description = "重定向URL")
    private String redirect;

    @Schema(description = "后端权限编码")
    private String permissionCode;

    @Schema(description = "是否外链")
    private Integer isExternal;

    @Schema(description = "是否缓存")
    private Integer isCache;

    @Schema(description = "是否显示")
    private Integer isVisible;

    @Schema(description = "排序号")
    @Min(value = 0, message = "排序号不能小于0")
    private Integer sortOrder;

    @Schema(description = "菜单描述")
    @Size(max = 500, message = "菜单描述长度不能超过500个字符")
    private String description;
}
